﻿using ZR.Model;
using ZR.Model.System;
using ZR.ServiceCore.Services.IService;

namespace ZR.Admin.WebApi.Controllers.System;
[Route("base/codeRule")]
public class BaseCodeRuleController : BaseController
{
    private static readonly NLog.Logger Logger = NLog.LogManager.GetCurrentClassLogger();
    
    private readonly IBaseCodeRuleService _baseCodeRuleService;

    public BaseCodeRuleController(IBaseCodeRuleService baseCodeRuleService)
    {
        _baseCodeRuleService = baseCodeRuleService;
    }
    
    [HttpPost("addBaseCodeRule")]
    public async Task<IActionResult> AddBaseCodeRule([FromBody] BaseCodeRule baseCodeRule)
    {
        var result = await _baseCodeRuleService.InsertBaseCodeRuleAsync(baseCodeRule);
        return SUCCESS(result);
    }
    
    [HttpDelete("deleteBaseCodeRule/{code}")]
    public async Task<IActionResult> DeleteBaseCodeRule(string code)
    {
        var result = await _baseCodeRuleService.DeleteBaseCodeRuleAsync(code);
        return SUCCESS(result);
    }
    
    [HttpPut("updateBaseCodeRule")]
    public async Task<IActionResult> UpdateBaseCodeRule([FromBody] BaseCodeRule baseCodeRule)
    {
        var result = await _baseCodeRuleService.UpdateBaseCodeRule(baseCodeRule);
        return SUCCESS(result);
    }
    
    [HttpGet("getBaseCodeRuleList")]
    public IActionResult GetBaseCodeRuleList([FromQuery] BaseCodeRule baseCodeRule, [FromQuery] PagerInfo pagerInfo)
    {
        var result = _baseCodeRuleService.SelectBaseCodeRulePage(baseCodeRule, pagerInfo);
        return SUCCESS(result);
    }
}